
{# <!-- Iterate through and render cards --> #}

{% set card_bg_color = cycler("", "background-color:#f7f7f7;") %}
{% for card_info in data.items -%}
    {# <!-- set border color --> #}
    {% if card_info.type == "dataverse" %}
       {% set card_border_color = "#c55b28" %}
    {% elif card_info.type == "dataset" %}
       {% set card_border_color = "#428bca" %}
    {% elif card_info.type == "file" %}
       {% set card_border_color = "#ccc" %}
    {% endif %}

    <div style="border:1px solid {{ card_border_color }};padding:4px 10px; margin-bottom:20px; overflow: hidden; font-size: 90%; {{ card_bg_color.next() }}">
        <div class="card-title-icon-block" style="font-size: 110%;"> 
 {% if card_info.type == "dataverse" %}
            <span class="icon-dataverse text-brand pull-right" title="Dataverse"></span>
            <a href="/dataverse/{{ card_info.identifier }}"><span style="padding:4px 0;">{{ card_info.name }}</span></a>
           {# <span class="text-muted">(<em>Affiliation</em>)</span>#}
  {% elif card_info.type == "dataset" %}
            <span class="icon-dataset text-info pull-right" title="Dataset"></span>
        {% if card_info.is_draft_state %}
            <a href="/dataset.xhtml?persistentId={{ card_info.global_id }}&version=DRAFT"><span style="padding:4px 0;">{{ card_info.name }}</span></a>
        {% else %}
            <a href="/dataset.xhtml?persistentId={{ card_info.global_id }}"><span style="padding:4px 0;">{{ card_info.name }}</span></a>
        {% endif %}
 {% elif card_info.type == "file" %}
            <span class="icon-file text-muted pull-right" title="File"></span>
            <a href="/file.xhtml?fileId={{ card_info.entity_id }}"><span style="padding:4px 0;">{{ card_info.name }}</span></a>
 {% endif %}
        <!-- publication status -->
        {#({{ loop.index }})#} {% if card_info.is_draft_state %}<span class="label label-primary draft"></span> {% endif %}
        {% if card_info.is_in_review_state %}<span class="label label-success inreview"></span> {% endif %}
        {% if card_info.is_unpublished_state %}<span class="label label-warning unpublished"></span> {% endif %}
        {% if card_info.is_published %} <span class="label label-warning published"></span> {% endif %}
        {% if card_info.is_deaccesioned %} <span class="label label-danger deaccessioned"></span> {% endif %}
        {% if not card_info.is_valid %} <span class="label label-danger incomplete"></span> {% endif %}
        
        <!-- roles -->
        {% for role_name in card_info.user_roles %}
            <span class="label label-info">{{ role_name }}</span>
        {% endfor %}
        </div>
        
 {% if card_info.type == "dataverse" %}       
        <div class="card-preview-icon-block text-center" style="font-size: 110%;">
            <a href="/dataverse/{{ card_info.identifier }}"><span class="icon-dataverse text-brand"></span></a>
        </div>
        <span class="text-muted">{{ card_info.date_to_display_on_card }} 
            {% if card_info.parentId %}
                {% if card_info.parentId != card_info.identifier %}
                  -  <a href="/dataverse/{{ card_info.parent_alias }}">{{ card_info.parentName }}</a>
                {% endif %}
            {% endif %}
        </span>

        {% if parent_alias %}
        <a href="/dataverse/{{ parent_alias }}">{{ parent_alias }}</a>
        {% endif %}

 {% elif card_info.type == "dataset" %}
            <div class="card-preview-icon-block text-center">
                {% if card_info.is_draft_state %}
                <a href="/dataset.xhtml?persistentId={{ card_info.global_id }}&version=DRAFT"><span class="icon-dataset text-info"></span></a>
                {% else %}
                <a href="/dataset.xhtml?persistentId={{ card_info.global_id }}"><span class="icon-dataset text-info"></span></a>
                {% endif %}
            </div>
            <span class="text-muted">{{ card_info.date_to_display_on_card }}
                - <a href="/dataverse/{{ card_info.parent_alias }}">{{ card_info.parentName }}</a>
            </span>
            <span class="resultDatasetCitationBlock{%if card_info.is_deaccesioned %} bg-danger{% else %} bg-citation {% endif %}">
                {%if card_info.citationHtml %}{{ card_info.citationHtml|safe }}{% else %}{{ card_info.citation|safe }}{% endif %}</span>
            
 {% elif card_info.type == "file" %}
            <div class="card-preview-icon-block text-center">
                <a href="/file.xhtml?fileId={{ card_info.entity_id }}">
                        
                    {% if card_info.image_url %}
                        <img src="{{ card_info.image_url | replace("https://localhost", "")  }}?pfdrid_c=true" alt="file card" class="file_card_img" />
                    {% else %}
                        <span class="icon-file text-muted"></span>
                    {% endif %}
                </a>
            </div>
            <span class="text-muted">{{ card_info.date_to_display_on_card }}
                - <a href="/dataset.xhtml?persistentId={{ card_info.parentIdentifier }}">{{ card_info.parentName }}</a>
            </span>
            <br /><span class="text-muted">{{ card_info.file_type }}</span>
            <span class="text-muted"> - {{ card_info.size_in_bytes }} KB - </span>
            <span class="text-muted"> {{ card_info.checksum.type }}: {{ card_info.checksum.value }} </span>
            
{% endif %}
    <hr style="margin:.5em;border:0;"/>
    {%if card_info.is_deaccesioned %}
          {{ card_info.deaccession_reason }}
    {% else %}
        {% if card_info.description %}
        
            {{ card_info.description|truncate(250) }}
        {% endif %}
    {% endif %}
            
</div>   

{%- endfor %}
